<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>laymd</title>
    <link rel="stylesheet" href="layui/css/layui.css">
</head>
<body style="padding: 15px;">
<div>
    <form class="layui-form layui-form-pane" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">长输入框</label>
            <div class="layui-input-block">
                <input type="text" name="title" autocomplete="off" placeholder="请输入标题" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">短输入框</label>
            <div class="layui-input-inline">
                <input type="text" name="username" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">日期选择</label>
                <div class="layui-input-block">
                    <input type="text" name="date" id="date1" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">行内表单</label>
                <div class="layui-input-inline">
                    <input type="text" name="number" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码</label>
            <div class="layui-input-inline">
                <input type="password" name="password" placeholder="请输入密码" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">请务必填写用户名</div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">文本域</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入内容" class="layui-textarea"></textarea>
            </div>
        </div>

        <div class="layui-form-item" pane="">
            <div id="demo"># 初始数据放这里</div>
        </div>

        <div class="layui-form-item">
            <button type="button" class="layui-btn" id="c">跳转式提交</button>
        </div>
    </form>
</div>
</body>
<script src="layui/layui.js"></script>
<script src="laymd/marked.min.js"></script>
<script>
    layui.config({base: 'laymd/'}).use(['layer', 'laymd'], function(){
        var $ = layui.$,
            layer = layui.layer,
            laymd = layui.laymd;

        //实例化编辑器,可以多个实例
        var md = laymd('demo', {});

        //内容改变事件
        md.on('change', function () {
            //这里借用marked.js解析效率比HyperDown快,用户可自行找解析器
            this.setPreview(marked(this.getText()));
        });

        //初始化数据预览
        md.do('change');
    });
</script>
</html>
